package com.android.mios.model;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

public class Scene {

	public int serialNumber;
	public int id;
	public int room;
	public boolean active;
	public String name;
	public int state;
	public String comments;

	@Override
	public String toString() {
		if (name == null || name.length() == 0) {
			return "No name";
		} else {
			return name;
		}
	}

	public static List<Scene> findScenesByRoom(Map<String, Scene> allScenes,
			int serialNumber, int room) {
		List<Scene> scenes = new ArrayList<Scene>();
		Collection<Scene> allSceneConnection = allScenes.values();
		if (serialNumber == -1 && room == -1)
			scenes.addAll(allSceneConnection);
		else {
			for (Scene scene : allSceneConnection) {

				if (scene.serialNumber == serialNumber && scene.room == room) {
					scenes.add(scene);
				}
			}
		}
		return scenes;
	}

	public static Scene findScenesByID(Map<String, Scene> allScenes,
			int serialNumber, int id) {
		Collection<Scene> allSceneConnection = allScenes.values();
		for (Scene scene : allSceneConnection) {
			if (scene.serialNumber == serialNumber && scene.id == id) {
				return scene;
			}
		}
		return null;

	}
}
